const Router = require('koa-router')
const {upload,create,update,remove,restore,findAll} = require('../controller/goods.controller')
const {auth,hadAdminPermission} = require('../middleware/auth.middleware')
const {validator} = require('../middleware/goods.middleware')
// const a = require('../../test/file_text.html')
const router = new Router({prefix:'/goods'})

//商品图片上传接口
router.post('/upload',auth,hadAdminPermission,upload)
//发布商品接口
router.post('/',auth,hadAdminPermission,validator,create)
// router.get('/test',a)
//修改商品接口
router.put('/:id',auth,hadAdminPermission,validator,update)
//硬删除商品接口
// router.delete('/:id',auth,hadAdminPermission,remove)
router.post('/:id/off',auth,hadAdminPermission,remove)
router.post('/:id/on',auth,hadAdminPermission,restore)

//获取参数列表接口
router.get('/',auth,findAll)
module.exports = router